import pandas as pd
import xlwings as xw
import matplotlib.pyplot as plt
import os

file_path = os.path.join('../Files', '线性分析.xlsx')
df = pd.read_excel(file_path)
df = df[['A型号', 'B型号', 'C型号', 'D型号', 'E型号']]
finger = plt.figure()
plt.rcParams['font.sans-serif'] = ['SimHei']  # 解决中文乱码问题

df.boxplot(grid=False)  # U绘制箱型图并删除网格线

app = xw.App(visible=False, add_book=False)
workbook = app.books.open(file_path)

worksheet = workbook.sheets['Result']
worksheet.pictures.add(finger, name='图片1', update=True, left=500, top=10)  # 将绘制的沙箱图插入工作表
workbook.save()
workbook.close()
app.quit()
